package cn.iocoder.yudao.module.wine.controller.app.userfans;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.wine.controller.app.userfans.vo.*;
import cn.iocoder.yudao.module.wine.dal.dataobject.userfans.UserFansDO;
import cn.iocoder.yudao.module.wine.service.userfans.UserFansService;

@Tag(name = "用户 APP - 用户粉丝信息")
@RestController
@RequestMapping("/wine/user-fans")
@Validated
public class AppUserFansController {

    @Resource
    private UserFansService userFansService;

    @PostMapping("/subscribe")
    @Operation(summary = "关注/取关接口")
    public CommonResult<Integer> subscribe(@Valid @RequestBody AppUserFansSaveReqVO createReqVO) {
        return success(userFansService.subscribe(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新用户粉丝信息")
    public CommonResult<Boolean> updateUserFans(@Valid @RequestBody AppUserFansSaveReqVO updateReqVO) {
        userFansService.updateUserFans(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除用户粉丝信息")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteUserFans(@RequestParam("id") Long id) {
        userFansService.deleteUserFans(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得用户粉丝信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppUserFansRespVO> getUserFans(@RequestParam("id") Long id) {
        UserFansDO userFans = userFansService.getUserFans(id);
        return success(BeanUtils.toBean(userFans, AppUserFansRespVO.class));
    }


    @GetMapping("/fansList")
    @Operation(summary = "获得我的粉丝列表")
    public CommonResult<List<AppUserFansListVO>> getFansList(@Valid AppUserFansReqVO reqVO) {
        List<AppUserFansListVO> list = userFansService.getFansList(reqVO);
        return success(list);
    }

    @GetMapping("/subscribeList")
    @Operation(summary = "获得我的关注列表")
    public CommonResult<List<AppUserFansListVO>> getSubscribeList(@Valid AppUserFansReqVO reqVO) {
        List<AppUserFansListVO> list = userFansService.getSubscribeList(reqVO);
        return success(list);
    }


}
